package org.vidi.jms.transaction;

import org.vidi.jms.common.ConnectionUtils;
import org.vidi.jms.common.Constants;

import javax.jms.*;

/**
 * @author vidi
 */
public class Consumer {
    public static void main(String[] args) {
        try {
            QueueConnection connection = ConnectionUtils.getConnection();
            connection.start();
            QueueSession session = connection.createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);
            Queue queue = session.createQueue(Constants.BASE_JMS_QUEUE_NAME);
            QueueReceiver receiver = session.createReceiver(queue);
            TextMessage message = (TextMessage) receiver.receive();
            System.out.println(message.getText());
            session.close();
            connection.close();
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}
